import java.io.*;

import java.util.*;

import java.sql.*;

import javax.servlet.*;

import javax.servlet.http.*;





/**

 * This is a simple example of an HTTP Servlet.  It responds to the GET

 * method of the HTTP protocol.

 */

public class GreetingServlet extends HttpServlet {

    public void doGet(HttpServletRequest request, HttpServletResponse response)

    throws ServletException, IOException {

        response.setContentType("text/html");

        response.setBufferSize(8192);

       

        PrintWriter out = response.getWriter();

       

        // then write the data of the response

        out.println("<html>" + "<head><title>Sample Request and Response</title></head>");

       

        // then write the data of the response

        out.println("<body  bgcolor=\"#ffffff\">" +

                "<img src=\"duke.waving.gif\" alt=\"Duke waving\">" +

                "<h2>Hello, my name is Andrique. My hobby is Bird breeding. What are your name and hobby?</h2>" +

                "<form method=\"get\"><table>" +

                "<tr><td>uname<//td><td><input type=\"text\" name=\"username\" size=\"25\"><//td><//tr>" + "" +

                "<tr><td>hobby<//td><td><input type=\"text\" name=\"hobby\" size=\"25\"><//td><//tr>" + "" +
                
                "<tr><td>name<//td><td><input type=\"text\" name=\"name\" size=\"25\"><//td><//tr>" + "" +

                "<tr><td>address<//td><td><input type=\"text\" name=\"address\" size=\"25\"><//td><//tr>" + "" +
                
                "<tr><td>number<//td><td><input type=\"text\" name=\"number\" size=\"25\"><//td><//tr>" + "" +

                "<tr><td>email<//td><td><input type=\"text\" name=\"email\" size=\"25\"><//td><//tr>" + "" +

                "<tr><td colspan=2><input type=\"submit\" value=\"Submit\">" +

                "<input type=\"reset\" value=\"Reset\"><//td><//tr>" + "<//table></form>");

       

        String username = request.getParameter("username");

       

        if ((username != null) && (username.length() > 0)) {

            RequestDispatcher dispatcher =

                    getServletContext()

                    .getRequestDispatcher("/ResponseServlet");

           

            if (dispatcher != null) {

                dispatcher.include(request, response);

            }

        }

       

        out.println("</body></html>");

        out.close();

    }

   

    public String getServletInfo() {

        return "The Hello servlet says hello.";

    }

}